package com.spm.librarianmanagersystem.controller;

import com.spm.librarianmanagersystem.config.aop.WebLog;
import com.spm.librarianmanagersystem.service.NotificationService;
import com.spm.librarianmanagersystem.utils.JsonResult;
import com.spm.librarianmanagersystem.utils.UserContextHolder;
import com.spm.librarianmanagersystem.vo.NotificationsDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *  @Class: NotificationsInfoController
 *  @Author: Wu Yue
 *  @Time: 18:29 2022/4/4
 *  @Description:
 */
@RestController
@RequestMapping("/api/user")
public class NotificationsInfoController {

    @Autowired
    NotificationService notificationService;
    @WebLog(description = "消息通知")
    @GetMapping("/notifications")
    public JsonResult<Object> getNotifications(){
        String currentUserId = UserContextHolder.getCurrentUserId();
        List<NotificationsDetails> notificationsDetails;
        notificationsDetails = notificationService.getNotification(currentUserId);
        return new JsonResult<>(notificationsDetails, 0, "successfully");
    }
}
